package com.pls.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pls.dao.DAOFactory;

import com.pls.dao.UserDAO;
import com.pls.domain.Employee;
import com.pls.domain.EmployeeWorkstation;
import com.pls.domain.Seat;


/**
 * Servlet implementation class LoginServlet
 */
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();

		EmployeeWorkstation	 empwork = new EmployeeWorkstation();
		UserDAO userDao = DAOFactory.getUserDAO();
		
		try {
			empwork = userDao.userLoginByCredentials("donnavanessa.reganit@pointwest.com.ph", "10090");
			Employee object = empwork.getEmployee();
			Seat seat = empwork.getSeatDetails();
			
			out.print("<h2>Hello, " + object.getFirstName() +" "+ object.getLastName() + "!</h2>");
			
			     
			out.print("EmployeeID: " + object.getEmployeeId());
			out.print(" <br/>Email Address: " + object.getEmailAddress());
			out.print(" <br/>Position code: " + object.getPositionCode());
			out.print(" <br/>SeatCode" + seat.getSeatCode());
			out.print(" <br/>seat type" + seat.getSeatType());
			
			out.print(object.getClass());
		    out.print(seat.getClass());
		
		}
		
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
       
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			doGet(request, response);
	}

}
